<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
       #clock {
            width: 200px;
            height: 50px;
            line-height: 50px;
            background-color: black;
            color: #fff;
            display: flex;
            justify-content: center;
        }

        #clock div {
            position: relative;
            width: 50px;
        }

        #clock div .text {
            position: absolute;
            top: 0;
            right: 10px;
            font-size: 12px;
        }
</style>
<body>
    <div id="clock">
        <div>
            <span id="hours"></span>
            <span class="text"> 时 : </span>
        </div>

        <div>
            <span id="minutes"></span>
            <span class="text"> 分 : </span>
        </div>
        <div>
            <span id="seconds"></span>
            <span class="text">秒 </span>
        </div>
    </div>
        <script>
              function updateTime() {
        const now = new Date();
        const hours = now.getHours();
        const minutes = now.getMinutes();
        const seconds = now.getSeconds();
        const hoursFormatted = hours < 10 ? `0${hours}` : hours;
        const minutesFormatted = minutes < 10 ? `0${minutes}` : minutes;
        const secondsFormatted = seconds < 10 ? `0${seconds}` : seconds;
        const hoursElem = document.getElementById('hours');
        const minutesElem = document.getElementById('minutes');
        const secondsElem = document.getElementById('seconds');
        hoursElem.textContent = hoursFormatted;
        minutesElem.textContent = minutesFormatted;
        secondsElem.textContent = secondsFormatted;
    }

    setInterval(updateTime, 1000);
        </script>
</body>
</html>